from typing import Optional

from pydantic import BaseModel, Field
from decimal import Decimal

from app.models.camel_model import CamelModel


class BatteryCreate(CamelModel):
    battery_name: str = Field(..., max_length=100)
    max_output_power: Decimal = Field(..., description="最大输出功率")
    max_input_power: Decimal = Field(..., description="最大输入功率")
    capacity: Decimal = Field(..., description="电池容量")
    initial_capacity: Decimal = Field(..., description="初始容量")
    icon: Optional[str] = (
        '<svg t="1752646994365" class="icon" viewBox="0 0 1024 1024" '
        'version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5096" '
        'width="16" height="16"><path d="M85.33 256v640h853.33V256H85.33z '
        'm768 554.67H170.67V341.33h682.67v469.34zM170.67 128H384v85.33H170.67z" '
        'p-id="5097"></path><path d="M554.67 469.33h260.27v85.33H554.67zM298.67 '
        '640H384v-85.33h85.33v-85.34H384V384h-85.33v85.33h-89.6v85.34h89.6zM640 '
        '128h213.33v85.33H640z" p-id="5098"></path></svg>'
    )
    background: Optional[str] = Field(default="", description="背景")

class BatteryOut(CamelModel):
    battery_id: int
    battery_name: str
    max_output_power: Decimal
    max_input_power: Decimal
    capacity: Decimal
    initial_capacity: Decimal
    icon: Optional[str] = None
    background: Optional[str] = None

    model_config = {
        "from_attributes": True
    }
